// page/caicaicai/index.js
let numComputer
let numUser
Page({
  data:{
    history:[],
  },
  onLoad(options) {
    numComputer=parseInt(Math.random()*99+1)
    console.log('计算机箱的数据',numComputer)
  },
  guessData(e){
    numUser=parseInt(e.detail.value)
    console.log('用户猜的数据:',numUser)
  },
  caicaicai(e){
    let history=this.data.history
    history.push(numUser)
    if(history.length>8) history.shift()
    let result=null
    if(numUser>numComputer){
      result='猜大了'
    }else if(numUser<numComputer){
      result='猜小了'
    }else{
      result='猜对了'
    }
    this.setData({
      result:result,
      history,
      userData:null,
      focus:true
    })
  }
})